<?php

/**
 * Release filter form base class.
 *
 * @package    packagesdispenser
 * @subpackage filter
 * @author     Nicolas Surian aka NairuS <contact@nairus.fr>
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseReleaseFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'fail'       => new sfWidgetFormFilterInput(),
      'mode'       => new sfWidgetFormChoice(array('choices' => array('' => '', 'auto' => 'auto', 'manual' => 'manual'))),
      'status'     => new sfWidgetFormChoice(array('choices' => array('' => '', 'building' => 'building', 'completed' => 'completed', 'failed' => 'failed'))),
      'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'fail'       => new sfValidatorPass(array('required' => false)),
      'mode'       => new sfValidatorChoice(array('required' => false, 'choices' => array('auto' => 'auto', 'manual' => 'manual'))),
      'status'     => new sfValidatorChoice(array('required' => false, 'choices' => array('building' => 'building', 'completed' => 'completed', 'failed' => 'failed'))),
      'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('release_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Release';
  }

  public function getFields()
  {
    return array(
      'project_id' => 'Number',
      'version'    => 'Text',
      'fail'       => 'Text',
      'mode'       => 'Enum',
      'status'     => 'Enum',
      'created_at' => 'Date',
      'updated_at' => 'Date',
    );
  }
}
